package com.example.excelapache_poi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.excelapache_poi.dto.UserDto;
import com.example.excelapache_poi.entity.User;
import com.example.excelapache_poi.mapper.UserMapper;
import com.example.excelapache_poi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by IntelliJ IDEA2022.3.2
 * @Author: Tenghw
 * @Date: 2023/07/03  22:31
 * @Description:
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    /**
     * 上传/导入
     * @param file
     * @return responseEntity
     */
    @Override
    public ResponseEntity uploadExcel(MultipartFile file) {
        return null;
    }



    /**
     * 下载/导出
     * @param response
     * @param userDto
     * @return
     */
    @Override
    public void downLoadExcel(HttpServletResponse response, UserDto userDto) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
        queryWrapper.eq("id", userDto.getId());
        queryWrapper.eq("userName", userDto.getUserName());
        queryWrapper.orderByAsc("id");

        List<User> userList = userMapper.selectList(queryWrapper);
    }
}
